package com.example.eddie.test.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.example.eddie.test.MyAdapter.UserSettingAdapter;
import com.example.eddie.test.PoJo.UserSettingPoJo;
import com.example.eddie.test.R;

import java.util.ArrayList;
import java.util.List;

public class FouFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment04,container,false);

        init(view);

        return view;
    }

    private void init(View view) {
        ListView settingList = view.findViewById(R.id.show_user_info);
        List<UserSettingPoJo> list = new ArrayList<>();
        list.add(new UserSettingPoJo(getResources().getDrawable(R.drawable.button_shape),"123"));
        list.add(new UserSettingPoJo(getResources().getDrawable(R.drawable.button_shape),"456"));
        list.add(new UserSettingPoJo(getResources().getDrawable(R.drawable.button_shape),"789"));
        UserSettingAdapter settingAdapter = new UserSettingAdapter(getContext(),R.layout.user_setting_item,list);
        settingList.setAdapter(settingAdapter);

        settingList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(getContext(), "fff", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
